package com.gg.controller;

import com.gg.entity.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@CrossOrigin
@RestController
public class LoginController {
    @Autowired
    private KaptchaController kaptchaController;
    //验证码
    @GetMapping("/captcha")
    public ResultData login(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,String code){
        //从session中取出验证码字符串
        String verifyCode = kaptchaController.code;
//        String verifyCode = (String)httpServletRequest.getSession().getAttribute("verifyCode");
        System.out.println(verifyCode);
        if(code.equalsIgnoreCase(verifyCode) ){
//            System.out.println(666);
            return new ResultData(200,"验证成功");
        }
//        System.out.println(111);
        return new ResultData(444,"验证失败");
    }
}
